
<meta charset="utf-8" />	
<form class="form-horizontal" role="form"  onsubmit="return submitForm(this);"
 action="mpcoop/cooporgmer/coopOrgMerAdd/add.do" id="cooporgMeradd_form">
 <br/>
	<!-- 
	 * Input属性说明:
	 * validate="true"  是否需要验证字段
	 * msg="错误时提示信息"        
	 * datatype="数据类型"
	-->
	<!-- #section:elements.form -->
		<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 合作机构编号： </label>
		<div class="col-sm-4">
                <label>
					<div class="search_input" style="padding-top: 5px;">
						 <select  name="cooporgNo" id="cooporgNo" data-placeholder="请选择合作机构编号"  style="width: 258px;vertical-align:middle;">
							
						 </select>
					</div>
				</label>
		</div>
		
	</div>
	
	<div class="form-group">
		 <label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 商户编号： </label>
		<div class="col-sm-4">

			<input type="text" id="merNo" name="merNo" placeholder="请输入[商户编号]" 
				class="col-xs-10 col-sm-7" validate="true" />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 商户名称： </label>
		<div class="col-sm-4">

			<input type="text" id="merName" name="merName" placeholder="请输入[商户名称]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 主密钥： </label>
		<div class="col-sm-4">

			<input type="text" id="merKey" name="merKey" placeholder="请输入[商户密钥(快捷通道/终端主密钥)]" 
				class="col-xs-10 col-sm-7"  validate="true"/>
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 主密钥校验值： </label>
		<div class="col-sm-4">

			<input type="text" id="checkValue" name="checkValue" placeholder="请输入[主密钥校验值]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 日交易限额： </label>
		<div class="col-sm-4">

			<input type="text" id="dtLimit" name="dtLimit" placeholder="请输入[日交易限额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 月交易限额： </label>
		<div class="col-sm-4">

			<input type="text" id="mtLimit" name="mtLimit" placeholder="请输入[月交易限额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>
	<div class="form-group">
		
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 单笔最低交易额： </label>
		<div class="col-sm-4">

			<input type="text" id="lowLimit" name="lowLimit" placeholder="请输入[单笔最低交易额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 单笔最高交易额： </label>
		<div class="col-sm-4">

			<input type="text" id="highLimit" name="highLimit" placeholder="请输入[单笔最高交易额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 商户状态: </label>
		<div class="col-sm-4">
             <select 
						rel="obj.MERSTATUS"
						location="local" 
						name="merStatus" 
						id="merStatus" 
						data-placeholder="请选择状态" style="width: 120px;vertical-align:middle;">
						<option value='' >--请选择--</option>
			</select>
		</div>
		
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 路由商户编号： </label>
		<div class="col-sm-4">
			<input type="text" id="routeMerId" name="routeMerId"  
				class="col-xs-10 col-sm-7" data-placeholder="需要绑定的系统商户编号" />
				
			<input type="hidden" id="editUserName" name="editUserName"  
				class="col-xs-10 col-sm-7" readonly="readonly" />
		</div>
		
		<!-- <label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 编辑员： </label>
		<div class="col-sm-4">

			<input type="text" id="editUserName" name="editUserName"  
				class="col-xs-10 col-sm-7" readonly="readonly" />
		</div> -->
	</div>
	<input type="hidden" id="editUserId" name="editUserId" />

<div class="form-group" >
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 终端编号： </label>
				<div class="col-sm-4">
		
					<input type="text" id="terNo" name="terNo" placeholder="请输入[终端编号]" 
						class="col-xs-10 col-sm-7"  />
				</div>
				
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 费率类型: </label>
				<div class="col-sm-4">
		        <select 
								rel="obj.RATETYPE"
								location="local" 
								name="rateType" 
								id="rateType" 
								data-placeholder="请选择类型" style="width: 120px;vertical-align:middle;">
								<option value='' >--请选择--</option>
					  </select>
				</div>
		</div>

<!-- 合作机构类型为收单 -->
<div class="form-group"  id="pos_div">
		
		<div class="form-group" >
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 费率封顶： </label>
				<div class="col-sm-4">
		
					<input type="text" id="rateTop" name="rateTop" placeholder="请输入[费率封顶]" 
						class="col-xs-10 col-sm-7"  />
				</div>
				
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 费率类型 封顶金额： </label>
				<div class="col-sm-4">
		
					<input type="text" id="rateTypeTop" name="rateTypeTop" placeholder="请输入[费率类型 封顶金额]" 
						class="col-xs-10 col-sm-7"  />
				</div>
		</div>
</div>

<!-- 合作机构类型为快捷 -->
<div class="form-group" id="shortcut_div" style="display: none;">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> T0成本费率(%)： </label>
		<div class="col-sm-4">

			<input type="text" id="rateT0" name="rateT0" placeholder="请输入[大商户T0刷卡成本费率(%)]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> T1成本费率(%)： </label>
		<div class="col-sm-4">

			<input type="text" id="rateT1" name="rateT1" placeholder="请输入[大商户T1刷卡成本费率(%)]" 
				class="col-xs-10 col-sm-7"  />
		</div>
</div>
	
	
	<div class="form-actions align-right  form-button-box" style="margin-top: 10px">
			<button class="btn btn-info" type="submit" >
				保存
			</button>

			&nbsp; 
			<button class="btn" type="button" onclick="javascript:dialog.close(this);">
				 关闭
			</button>
		</div>
	
</form>
<script type="text/javascript">
<!--

//-->

/**
 * 	初始化下拉框
 */
$(document).ready(function() {
	 loadOption("cooporgNo","","0","mpcoop/selectoption/cooporgNo.do");
	 var p = dialog.getById('dlg-coopOrgMerAdd');
	//设置页面初始值
	$("#editUserId").attr("value",p.dataParam.editUserId);
	$("#editUserName").attr("value",p.dataParam.editUserName);
	
});

/**
 * 验证合作机构的类型
 */
$(document).ready(function(){
    $('#cooporgNo').change(
			 function (){
				 var p1=$(this).children('option:selected').val();
				 $.ajax({
						type : "post",
						url : "mpcoop/coopManage/queryCoopTypeById.do",
						data:{cooporgNo:p1},
						dataType : 'json',
						async:true,
						success : function(result) {
							if (result.rspcod != 200) {
								msg.alert("错误", result.rspmsg + " 错误代码："+ result.rspcod, 'error');
							} else {
								coopType=result.obj.coopType;
								if(coopType == "0" ){//收单
									$("#pos_div").show();
									$("#shortcut_div").hide();
								}
								if(coopType == "1" ){
									$("#pos_div").hide();
									$("#shortcut_div").show();
								}
							}
						},
						error : function(XMLHttpRequest, textStatus) {
							msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
						}
					});
			 }
	 ); 
     $('#rateType').change(
    		function(){
			    var rateType=$(this).children('option:selected').val();
				if(rateType == '1' || rateType == '2' || rateType == '3' ){
					$("#rateTypeTop").attr("disabled","disabled");    			
				}else if(rateType == '4' || rateType == '5'){
					$("#rateTypeTop").removeAttr("disabled");
				}
    		}	
	); 
   
});


function submitForm(obj){
	var merStatus=$("#merStatus option:selected").val();
	if(merStatus==''){
		alertMsg.error('请选择商户状态');
		return false;
	}
	if($("#pos_div").is(":visible")){
		var rateType=$("#rateType option:selected").val();
		if(rateType==''){
			alertMsg.error('请选择费率类型');
			return false;
		}
		if(rateType == '4' || rateType == '5'){
			var rateTypeTop=$("rateTypeTop").val();
			if(rateTypeTop==''){
				alertMsg.error('请输入费率类型 封顶金额');
				return false;
			}
		}
	}
	return validateCallback(obj,editUserDone);
}

function editUserDone(result){
	dialogAjaxDone(result);
	if(result.rspcod== 200){
		msg.alert("提示",result.rspmsg,'correct');
		$("#grid-table").trigger("reloadGrid");
		dialog.closeById('dlg-coopOrgMerAdd');
	}else{
		msg.alert("错误",result.rspmsg+" 错误代码："+result.rspcod,'error');
	}
}
	
</script>